import 'string_apis.dart'; // Contains NumberParsing extension
import 'string_apis_2.dart'; // Contains NumberParsing2 extension
import 'string_apis_3.dart' as rad; // Contains NumberParsing3 extension
import 'my_fancy_list.dart'; 
void main() {

  //https://dart.cn/language/extension-methods/#overview
  print(NumberParsing('42').parseInt()); // Use an extension method.


  //https://dart.cn/language/extension-methods/#using-extension-methods
print('42'.padLeft(5)); // Use a String method.
 
 

 //https://dart.cn/language/extension-methods/#api-conflicts
 // Use NumberParsing extension from string_apis.dart
  print(NumberParsing('42').parseInt()); // Output: 42

  // Use NumberParsing2 extension from string_apis_2.dart
  print(NumberParsing2('42').parseInt()); // Output: 42

  // Use NumberParsing3 extension from string_apis_3.dart
  print(rad.NumberParsing3('42').parseInt()); // Output: 42

  // Use parseNum from NumberParsing3 extension
  print(rad.NumberParsing3('3.14').parseNum()); // Output: 3.14


  //https://dart.cn/language/extension-methods/#static-types-and-dynamic
dynamic d = '2';
print(d.parseInt()); // Runtime exception: NoSuchMethodError

//https://dart.cn/language/extension-methods/#api-conflicts
// Use the ParseNumbers extension from string_apis_3.dart.
  print(rad.NumberParsing3('42').parseInt());

  // Only string_apis_3.dart has parseNum().
  print('42'.parseNum());


  print(NumberParsing2('42').parseInt());
  print(NumberParsing2('42').parseInt());

  


//https://dart.cn/language/extension-methods/#implementing-generic-extensions
  // 使用 MyFancyList 扩展
  var list = [1, 2, 3, 4, 5];
  print(list.doubleLength); // 输出: 10
  print(-list); // 输出: [5, 4, 3, 2, 1]
  print(list.split(3)); // 输出: [[1, 2, 3], [4, 5]]




}
